﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using ITProject.Domain.Entities;

namespace ITProject.WebUI.Models.ProjectAdmin
{
    public class ProjectAdminProjectTaskViewModel
    {
        [Display(Name="Nazwa")]
        public string Name { get; set; }
        [Display(Name="Przypisane do")]
        public string Receiver { get; set; }
        [Display(Name = "Status")]
        public string Status { get; set; }
        // ukryte
        public int TaskId { get; set; }

        public static ProjectAdminProjectTaskViewModel[] Convert(Task[] tasks, string[] receivers)
        {
            ProjectAdminProjectTaskViewModel[] vmTab = new ProjectAdminProjectTaskViewModel[tasks.Length];
            for (int i = 0; i < vmTab.Length; i++)
            {
                vmTab[i] = new ProjectAdminProjectTaskViewModel();
                vmTab[i].Name = tasks[i].Name;
                vmTab[i].TaskId = tasks[i].Id;
                vmTab[i].Receiver = receivers[i];
                vmTab[i].Status = StatusName.ConvertFromByte(tasks[i].Status);
            }
            return vmTab;
        }
    }
}